<!-- head -->
{include file='public/head' /}
<!-- head -->
<!-- left -->
{include file='public/left' /}
<!-- left -->

<div class="content-wrapper">
    <section class="content-header">
        <h1>
            添加图片
            <small>图片库信息</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 项目管理</a></li>
            <li>图片库</li>
            <li class="active">添加</li>
        </ol>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <!-- Horizontal Form -->
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">填写信息</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form name="form1" class="form-horizontal" method="post" action="{:url('admin/Item/addImgweb','','')}" enctype="multipart/form-data">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="img" class="col-sm-2 control-label">项目分类</label>
                                <div class="col-sm-5">
                                    <select class="form-control select2" name="country" id="country" onChange="getCity()">
                                        <option selected="selected" value="-1">请选择状态</option>
                                        {volist name='data' id='admin'}
                                        <option value="{$admin.id}">{$admin.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                                <div class="col-sm-5">
                                    <select class="form-control select2" name="city" id="city">
                                        <option selected="selected" value="-1">请选择状态</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="img" class="col-sm-2 control-label">图片</label>
                                <div class="col-sm-10">
                                    <input type="file" id="photo" name='img'>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPassword3" class="col-sm-2 control-label">发送端</label>
                                <div class="col-sm-10">
                                    <div class="checkbox">
                                        <label>
                                            <input type="radio" checked="checked" id='custom' name="user" value="0"> 项目图片
                                        </label>
                                        <label>
                                            <input type="radio" id='staff' name="user" value="1"> 新项目广告图
                                        </label>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-info pull-right" name="submit" value="3">添加</button>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script type="text/javascript">
    function getCity() {
        var options = $("#country option:selected").val();  //获取选中的项
        $.ajax({
            url: "{:url('admin/Item/selectclass','','')}",
            type: 'GET',
            data: {
                'id': options,
            },
            dataType: 'JSON',
            success: function (data) {
                var arr = data;
                var dataObj = eval("(" + arr + ")");
                var data = dataObj.data;
                //var sltCity = document.form1.city;     //获得城市下拉框的对象  
                var obj = document.getElementById('city');
                obj.options.length = 0;
                for (var i = 0; i < data.length; i++) {
                    //sltCity[i + 1] = new Option(data[i]['name'], data[i]['name']);
                    $("#city").append("<option value='" + data[i]['id'] + "'>" + data[i]['name'] + "</option>");
                }
                console.log(data);
            }
        });
    }
</script>  
<!-- foot -->
{include file='public/foot' /}
<!-- foot -->